//局部刷新分页 -- 跳转

function turnPage(ele, id, contentId, path, params, strJSON) {
	//showLoader();
	
	
	var eleId = ele.attr('id');
	var eleIdArr = eleId.split("-");

	if(eleIdArr[2] == "none") {
		return false;
	}

	var jsonObj = new Function("return " + strJSON)();
	
	if(eleIdArr[1]=="first") { //首页
		$("#" + contentId).load(path+"?pageNum=1" + params + "&t=" + Math.random(),jsonObj,
			function(){
				
			}
		);
			
		return false;
	}
	
	if(eleIdArr[1]=="pre") {//上一页	
		if(eleIdArr[2] == "1"){
		
		} else {
			var pageNum = eleIdArr[2]-1;
			$("#" + contentId).load(path+"?pageNum=" + pageNum + params + "&t=" + Math.random(), jsonObj,
				function(){
					
				}
			);
		}
	
		return false;
	}
	
	if(eleIdArr[1]=="next") {//下一页
		if(eleIdArr[2] == eleIdArr[3]){
		
		} else {
			var pageNum = eleIdArr[2]-0+1;
			$("#" + contentId).load(path+"?pageNum=" + pageNum + params + "&t=" + Math.random(), jsonObj,
				function(){
					
				}
			);
		}
	
		return false;
	} 
	
	if(eleIdArr[1]=="last") { //尾页
		$("#" + contentId).load(path+"?pageNum=" + eleIdArr[3] + params + "&t=" + Math.random(), jsonObj,
			function(){
				
			}
		);

		return false;
	}		
	
	$("#" + contentId).load(path+"?pageNum="+eleIdArr[1]+params + "&t=" + Math.random(), jsonObj,
		function(){
			
		}
	);
	return false;
}

function directToPage(obj, curPage, contentId, path, params, strJSON) {
	var jsonObj = new Function("return " + strJSON)();
	
	var page = obj.val();
	if(page == "" || page == curPage) {
		return false;
	} else {
		$("#" + contentId).load(path+"?pageNum=" + page + params + "&t=" + Math.random(), jsonObj,
			function(){
				
			}
		);
	}
}




//局部刷新分页 -- 各个页码

function everyPage(ele, id, contentId, path, params) {
	//showLoader();
	var eleId = ele.attr('id');
	var eleIdArr = eleId.split("-");

	if(eleIdArr[2] == "none") {
		return false;
	}
	
	if(eleIdArr[1]=="first") { //首页
		$("#" + contentId).load(path+"?pageNum=1"+params + "&t=" + Math.random(), 
			function(){
				//$("#" + id + "-" + eleIdArr[2]).attr({'class' : 'page'});	
				//$("#" + id + "-1").attr({'class' : 'cur'});	
				changeStyle(id, 1);
			}
		);
			
		return false;
	}
	
	if(eleIdArr[1]=="pre") {//上一页	
		if(eleIdArr[2] == "1"){
		
		} else {
			var pageNum = eleIdArr[2]-1;
			$("#" + contentId).load(path+"?pageNum=" + pageNum + params + "&t=" + Math.random(), 
				function(){
					//$("#" + id + "-" + eleIdArr[2]).attr({'class' : 'page'});	
					//$("#" + id + "-" + pageNum).attr({'class' : 'cur'});	
					changeStyle(id, pageNum);
				}
			);
		}
	
		return false;
	}
	
	if(eleIdArr[1]=="next") {//下一页
		if(eleIdArr[2] == eleIdArr[3]){
		
		} else {
			var pageNum = eleIdArr[2]-0+1;
			$("#" + contentId).load(path+"?pageNum=" + pageNum + params + "&t=" + Math.random(), 
				function(){
					//$("#" + id + "-" + eleIdArr[2]).attr({'class' : 'page'});	
					//$("#" + id + "-" + pageNum).attr({'class' : 'cur'});	
					changeStyle(id, pageNum);
				}
			);
		}
	
		return false;
	} 
	
	if(eleIdArr[1]=="last") { //尾页
		$("#" + contentId).load(path+"?pageNum=" + eleIdArr[3] + params + "&t=" + Math.random(), 
			function(){
				//$("#" + id + "-" + eleIdArr[2]).attr({'class' : 'page'});	
				//$("#" + id + "-" + eleIdArr[3]).attr({'class' : 'cur'});	
				changeStyle(id, eleIdArr[3]);
			}
		);
		
		
		return false;
	}		
	
	$("#" + contentId).load(path+"?pageNum="+eleIdArr[1]+params + "&t=" + Math.random(), 
		function(){
			//$("#" + id + " li").attr({'class' : 'page'});	
			//$("#" + id + "-" + eleIdArr[1]).attr({'class' : 'cur'});
			changeStyle(id, eleIdArr[1]);
		}
	);
	return false;
}

function changeStyle(id, cur) {
	//alert(cur);
	$("#" + id + " li").attr({'class' : 'page'});	
	$("#" + id + "-" + cur).attr({'class' : 'cur'});
}


function showLoader(){
	
	$('.search-background').fadeIn(200);
}
	
function hideLoader(){

	$('.search-background').fadeOut(200);
};
		
	

